local ClientOHOH = _G.ClientOHOH;

local M = ClientOHOH.class.new(script, ClientOHOH.files.OHOHOLYBUIBase());
local BigNumberHelper = ClientOHOH.load.BigNumberHelper();


function InitInsts(ui)
	ui.insts = {};
	ui.insts.LevelLable ="ctrl.player.leve"
	
	ui.insts.HpLable ="ctrl.HP.num"
	ui.insts.HpScale ="ctrl.HP.clipping"

	ui.insts.ExpLable ="ctrl.EXP.num"
	ui.insts.ExpScale ="ctrl.EXP.clipping"
	ui.insts.Exp_percent ="ctrl.EXP.percentage"
	
end


function M.new(...)
	return M(...);
end;
function M.ctor(self)
	InitInsts(self)

	M.super.ctor(self, ClientOHOH:GetPath_Loop("ReplicatedStorage.Resource.UI.PlayerBattleInfoGui"));

	self.Items={
		base_hp=self.insts.HpLable,
		base_exp=self.insts.ExpLable
	}
end;


function M.dtor(self)
	M.super.dtor(self);
end;


function M.UpdateHp(self,hp1,maxHp)
	
	hp1=hp1 or 100
	maxHp=maxHp or 100

	local hp1str=BigNumberHelper:ToString(hp1)
	local maxHpstr=BigNumberHelper:ToString(maxHp)
	local hpScale=hp1/maxHp
	self.insts.HpLable.Text=hp1str.."/"..maxHpstr
	self.insts.HpScale.Size=UDim2.fromScale(hpScale,1)
end

function M.UpdateExp(self,exp1,maxExp)
	exp1=exp1 or 100
	maxExp=maxExp or 100

	local exp1str=BigNumberHelper:ToString(exp1)
	local maxExpstr=BigNumberHelper:ToString(maxExp)
	local expScale=exp1/maxExp
	if expScale>1 then
		expScale=1
	end
	self.insts.ExpLable.Text=exp1str.."/"..maxExpstr
	self.insts.ExpScale.Size=UDim2.fromScale(expScale,1)
	local p1000=math.floor(expScale*1000+0.5)
	self.insts.Exp_percent.Text=(p1000/10).."%"
end

function M.AddItem(self,item_id,count)	
	local lable= self.Items[item_id]
	require(lable.AddCtrl.Animation).play(count)
end


function M.UpdateLevel(self,level)
	level=level or 1
	self.insts.LevelLable.Text="Lv."..level
end
return M
